package com.model.model02.demo03.context;

import com.model.model02.demo02.discount.CashNormal;
import com.model.model02.demo02.discount.CashRebate;
import com.model.model02.demo02.discount.CashReturn;
import com.model.model02.demo02.discount.abs.CashSuper;

public class CashContext {

    CashSuper cs;

    public CashContext(int discount) {
        switch(discount) {
            case 0: cs = new CashNormal(); break;
            case 1: cs = new CashReturn(300, 100); break;
            case 2: cs = new CashRebate(0.8); break;         default:
                cs = new CashNormal();
                System.out.println("暂无对应折扣, 按原价计算");
                break;
        }
    }


    public double getResult(double money) {
        return cs.acceptCash(money);
    }

}
